package com.hxm.appGenealogy.config;

import com.aliyun.oss.ClientBuilderConfiguration;
import com.aliyun.oss.OSS;
import com.aliyun.oss.OSSClientBuilder;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class OssConfig {

    @Value("${huangye.aliyun.endpoint}")
    String endpoints;

    @Value("${huangye.aliyun.accessKeyId}")
    String accessKeyIds;


    @Value("${huangye.aliyun.accessKeySecret}")
    String accessKeySecrets;


    @Bean()
    public OSS ossClient() {
        ClientBuilderConfiguration conf = new ClientBuilderConfiguration();
        // 设置是否支持CNAME。CNAME用于将自定义域名绑定到目标Bucket。
        conf.setSupportCname(true);
        // 创建OSSClient实例。
        OSS ossClient = new OSSClientBuilder().build(endpoints, accessKeyIds, accessKeySecrets, conf);
        return ossClient;
    }
}
